package com.dong.auth.security.authentication;

import com.dong.auth.security.userdetails.SecurityUser;

import java.io.Serializable;
import java.util.Collection;

public class Authentication implements Serializable {

    /**
     * 登录用户的信息
     */
    private SecurityUser userDetail;

    /**
     * 登录帐号
     */
    private String accessCode ;
    /**
     * 登录帐号的密钥
     */
    private String credentials;
    /**
     * 用户的权限集合
     */
    private Collection<String> authorities;
    /**
     * 是否已经授权，默认为false
     */
    private boolean authenticated = false;

    public Authentication() {
    }

    public Authentication(String accessKey, String credentials) {
        this.accessCode = accessKey;
        this.credentials = credentials;
    }

    public SecurityUser getUserDetail() {
        return userDetail;
    }

    public void setUserDetail(SecurityUser userDetail) {
        this.userDetail = userDetail;
    }

    public String getAccessCode() {
        return accessCode;
    }

    public void setAccessCode(String accessCode) {
        this.accessCode = accessCode;
    }

    public String getCredentials() {
        return credentials;
    }

    public void setCredentials(String credentials) {
        this.credentials = credentials;
    }

    public Collection<String> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(Collection<String> authorities) {
        this.authorities = authorities;
    }

    public boolean isAuthenticated() {
        return authenticated;
    }

    public void setAuthenticated(boolean authenticated) {
        this.authenticated = authenticated;
    }

    public static Authentication ofLogin(String username,String password){
        return new Authentication(username,password);
    }
}
